using System;
using System.Collections.Generic;
using System.Text;

namespace Adoor.Object.Domain
{
    class EditorTest : System.ComponentModel.Design.CollectionEditor
    {
    private Type[] m_Types;

    public EditorTest(Type type ):base(type)
    {
        m_Types = new System.Type[] { typeof(LinkedDomainGroup) };
    }
    protected override Type[] CreateNewItemTypes() {
        return m_Types;
    }

        protected override object CreateInstance(Type itemType)
        {
             
            object obj = base.CreateInstance(itemType);
            if (typeof(LinkedDomainGroup).IsAssignableFrom(obj.GetType()))
            {
                LinkedDomainGroup group = ((LinkedDomainGroup)obj);
                group.ObjectResolver = ((LinkedDomainObjectResolver)this.Context.Instance);
            }
            return obj;
        }
    }

    class EditorTest3 : System.ComponentModel.Design.CollectionEditor
    {
        private Type[] m_Types;

        public EditorTest3(Type type)
            : base(type)
        {
            m_Types = new System.Type[] { typeof(ObjectDomain) };
        }
        protected override Type[] CreateNewItemTypes()
        {
            return m_Types;
        }

        protected override object CreateInstance(Type itemType)
        {
            object obj = base.CreateInstance(itemType);
            //if (typeof(ObjectDomain).IsAssignableFrom(obj.GetType()))
            //{
                ObjectDomain domain = ((ObjectDomain)obj);
                domain.DomainGroup = ((LinkedDomainGroup)this.Context.Instance);
            //}
            return obj;
        }
    }
    class EditorTest2 : System.ComponentModel.Design.CollectionEditor
    {
        private Type[] m_Types;

        public EditorTest2(Type type)
            : base(type)
        {
            m_Types = new System.Type[] { typeof(ObjectDomain) };
        }
        protected override Type[] CreateNewItemTypes()
        {
            return m_Types;
        }

        protected override object CreateInstance(Type itemType)
        {
            object obj = base.CreateInstance(itemType);
            //if (typeof(LinkedDomainGroup).IsAssignableFrom(obj.GetType()))
            //{
                LinkedDomainGroup group = ((LinkedDomainGroup)obj);
                group.ObjectResolver = ((LinkedDomainObjectResolver)this.Context.Instance);
            //}
            return obj;
        }
    }
}
